{extend name="public/base" /}
{block name="head"}
    <meta charset="UTF-8">
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <link href="/resource/ui-framework/easyui-1.5.2/themes/metro/easyui-c5a176a3d4.css" rel="stylesheet" />
    <link href="/resource/ui-framework/easyui-1.5.2/themes/icon-77a4ded0c8.css" rel="stylesheet" />

    <link href="/resource/ui-framework/bootstrap/3.0.3/css/bootstrap-a067b6d831.min.css" rel="stylesheet" />
    <link href="/resource/ui-framework/bootstrap-daterangepicker/css/daterangepicker-886dba62c4.css" rel="stylesheet" />
    <link href="/resource/ui-framework/font-awesome/css/font-awesome-a81d284b37.css" rel="stylesheet" />

    <link href="/resource/ui-framework/admin-lte/css/AdminLET-7d58b99a7e.css" rel="stylesheet" />
    <link href="/static/css/base-dc47892812.css" rel="stylesheet" />

    <link href="/resource/ui-framework/jason/searchbox/css/searchbox-398327fb84.css" rel="stylesheet" />
    <link href="/resource/ui-framework/jason/pager/css/pager-f077f5e880.css" rel="stylesheet" />
    <link href="/resource/ui-framework/jason/status/css/status-5f59ab3856.css" rel="stylesheet" />
    <link href="/resource/ui-framework/jason/selector/css/selector-23060c280e.css" rel="stylesheet" />
    <link href="/resource/ui-framework/jason/button/css/button-5ef10c798a.css" rel="stylesheet" />
    <link href="/resource/ui-framework/jason/orderarrow/css/orderarrow-dcf8eba7d1.css" rel="stylesheet" />

    <link href="/static/css/table-0e491bc98f.css" rel="stylesheet" />
    <link href="/static/css/easyui-ext-372f902530.css" rel="stylesheet" />
{/block}
{block name="content"}
<section class="content">
                    

<div class="container" style="width:50%;">
    <div class="row mt20">
        <div>
            <ul>
                <li class="fl h31 ml10">岗位名：</li>
                <li class="ml10 fl">
                    <span class="textbox" style="width: 173px;"><input id="title" type="text" class="textbox-text validatebox-text textbox-prompt" autocomplete="off" tabindex="" placeholder="" style="margin: 0px; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 171px;">
                </li>
                <li class="ml10 fl">
                    <a class="btn-action" onclick="btnAdd()">添加岗位</a>
                </li>
            </ul>
        </div>
    </div>
    <div class="row mt20">
        <div style="position:relative;clear:both;top:10px;">
            <table class="order">
                <tbody>
                    <tr class="header">
                        <td>#</td>
                        <td>岗位名</td>
                        <td>操作</td>
                    </tr>
                </tbody>
                <tbody id="roles">  
                {volist name="data" id="vo" key="k"}
                <tr class="project">
                    <td>{$k}</td>
                    <td>{$vo.title}</td>
                    <td>
                        <a href="javascript:" onclick="editRole({$vo.id})">编辑</a>
                        {if condition="($vo.id neq 1) AND ($vo.id neq 3)"}             
                        <a href="javascript:" onclick="delRole({$vo.id})">删除</a>                                        
                        <a href="/index/Authgroup/rulelist?id={$vo.id}">设置权限</a>
                        {/if}
                    </td>
                </tr> 
                {/volist}
                </tbody>
            </table>
        </div>
    </div>
</div>
</section>
{/block}
{block name="script"}
<script src="/resource/libs/jquery/jquery-1-4ed679c998.11.3.min.js"></script>
<script src="/resource/libs/ajaxfileupload-20caa375ef.js"></script>
<script src="/resource/ui-framework/bootstrap/3.0.3/js/bootstrap-7b3098bda9.min.js"></script>
<script src="/resource/ui-framework/bootstrap-daterangepicker/js/moment-zh_cn-3d8809ccd6.js"></script>
<script src="/resource/ui-framework/bootstrap-daterangepicker/js/daterangepicker-bca1a72d19.js"></script>
<script src="/resource/ui-framework/admin-lte/app-bf15eda982.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script type="text/javascript">
    $().ready(function () {
        var url = $('#hdnURL').val();
        $('.sidebar .treeview').each(function (index, item) {
            var btn = $(this).children("a").first();
            var menu = $(this).children(".treeview-menu").first();
            $(this).find('a').each(function (index, item) {
                if ($(item).attr('href') == url) {
                    menu.show();
                    btn.children(".fa-angle-left").first().removeClass("fa-angle-left").addClass("fa-angle-down");
                }
            });
        });
    });
$('#btnSubmit').click(function(){
    $('.ajax-form').submit();
});
function editRole(id){
       layer.open({
           type:2,
           title: '<span style="height: 4rem;background: none" class="lay-title">编辑岗位</span>',
           area:['600px','500px'],
           content:'/index/Authgroup/edit/?id='+id,
       })
}
function delRole(id){
    layer.confirm('确定删除该岗位吗？', {}, function(){ 
        $.post('{:url("/index/Authgroup/del")}',{id:id},function(res){
            if(res.code == 1){
                layer.msg(res.msg);
                window.setTimeout(function(){
                    window.location.reload();
                },1000)
            }else{
                layer.msg(res.msg);
            }
        });
    }, function(){});
}
function btnAdd(){
    var title = $("#title").val();
    if(!title){
        layer.alert('请输入岗位名');
        return false;
    }
    $.post('{:url("/index/Authgroup/add")}',{title:title},function(res){
            if(res.code == 1){
                layer.msg(res.msg);
                window.setTimeout(function(){
                    window.location.reload();
                },1000)
            }else{
                layer.msg(res.msg);
            }
    });
}
</script>
{/block}